package com.doujia.pattern.singleton;

/**
 * 单例模式
 */
public class SingtetonInstance {

    private static SingtetonInstance instance = new SingtetonInstance();

    private SingtetonInstance(){
    }

    public static SingtetonInstance getInstance() {
        return instance;
    }

    public void doSomething(){
        System.out.println("do 1");
    }

    public static void main(String[] args) {
        SingtetonInstance instance1 = SingtetonInstance.getInstance();
        SingtetonInstance instance2 = SingtetonInstance.getInstance();
        SingtetonInstance instance3 = SingtetonInstance.getInstance();

        System.out.println(instance1 == instance2);
        System.out.println(instance1 == instance3);
    }
}
